package com.xianyun.book.service;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.xianyun.book.api.PayServiceI;
import com.xianyun.book.domain.gateway.PayGateway;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map;

/**
 * @author ytt
 */
@CatchAndLog
@Service
public class PayServiceImpl implements PayServiceI {

    @Resource
    private PayGateway payGateway;

    @Override
    public Response payOrderByOrderId(String orderId) {
        payGateway.finishPayment(orderId);
        return Response.buildSuccess();
    }

    @Override
    public SingleResponse<Map<String, Object>> getReadyPayInfoByOrderId(String orderId) {
        return SingleResponse.of(payGateway.createOrderPaymentAndGetInfo(orderId));
    }

}
